#include "TextureManager.h"

TextureManager* TextureManager::sm_pInstance = nullptr;

TextureManager::TextureManager(void)
{

}

TextureManager* TextureManager::GetInstance(void)
{
	if(!sm_pInstance)
		sm_pInstance = new TextureManager;
	return sm_pInstance;
}

void TextureManager::DeleteInstance(void)
{
	if(sm_pInstance)
	{
		delete sm_pInstance;
		sm_pInstance = nullptr;
	}
}

void TextureManager::Initialize(void)
{
}

int TextureManager::LoadTexture(const char* filename)
{
	IDirect3DTexture9* texture = RENDERER->LoadTexture(filename);

	if(!texture)
		return -1;

	m_vpTextures.push_back(texture);
	return m_vpTextures.size() - 1;
}

IDirect3DTexture9* TextureManager::GetTexture(int textureID)
{
	if(textureID >= 0 && textureID < (int)m_vpTextures.size())
	{
		return m_vpTextures[textureID];
	}

	return nullptr;
}